<link rel="stylesheet" type="text/css" href="<?php echo STATIC_URL . '/javascript/fancybox/jquery.fancybox-1.3.4.css?v=' . SKIN_VERSION ?>" />
<script type="text/javascript" src="<?php echo STATIC_URL . '/javascript/fancybox/jquery.mousewheel-3.0.4.pack.js?v=' . SKIN_VERSION ?>" ></script>
<script type="text/javascript" src="<?php echo STATIC_URL . '/javascript/fancybox/jquery.fancybox-1.3.4.js?v=' . SKIN_VERSION ?>"></script>

<div class="col_left">
    <div class="detail-container">
        <div id="slideImage">
            <div class="ContestPicture">
                <a class="pre_photo" title="Previous photo" ></a>
                <?php if(APP_INSTANCE == APP_INSTANCE_IMAGE):?>
                    <img id="image_detail" src="<?php echo $this->entry->getImageUrl(); ?>"/>
                    <?php if($this->contest->isViewEntryByTwoColumn()):?>
                        <a class="fullcreen" href="#fullcreen_content"></a>
                        <div style="display: none;">
                            <div id="fullcreen_content">
                                <div class="full_image">
                                    <img style="max-width: 780px" src="<?php echo $this->entry->getImageUrl(); ?>"/>
                                </div>
							</div>
                        </div>
                        <script type="text/javascript">
                            $(document).ready(function(){
                                $(".fullcreen").fancybox({
                                    'titlePosition'		: 'inside',
                                    'transitionIn'		: 'none',
                                    'transitionOut'		: 'none',
                                    'border'            : 5,
                                    'padding'           : 5,
                                    'margin'            : 5,
                                    'offset'            : $(".sm_fanpage_menu").position()
                                });
                            });
                        </script>
                    <?php endif;?>
                <?php else: ?>
                    <div class="photo_container img" id="image_detail">
                    <?php echo $this->entry->getEmbeddedCode() ?>
                    </div>
                <?php endif;?>
                <a class="next_photo" title="Next photo" ></a>
            </div>
            <div id="slidePaging">
                <div class="PreviousPage">
                    <a id="previous" data-page="<?php echo $this->arrListItemsCount['prev_page'];?>"
                       title="Previous page" href="javascript:void(0);"></a>
                </div>
                <div class="ThisPageImages">
                    <ul class="wrapper">
                        <?php
                            $list_image = array();
                            foreach ($this->paginator as $index => $entry) :
                                $list_image[$index] = $entry->getImageUrl();
                        ?>
                            <li class="thumbnail <?php if($entry->id == $this->entry->id) echo "Current";?>" data-entry="<?php echo $index;?>">
                                <a class="thumbnail"
                                   title="<?php echo $this->escape($entry->title) . ' - ' . $this->number($entry->votes,'LABEL_NUM_VOTE')?>"
                                    href="<?php echo $this->pageUrl(array_merge($this->extraValues,
                                            array('target' => 'detail', 'id_entry' => $entry->id))); ?>">
                                    <img src="<?php echo $entry->getThumbnailImageUrl() ?>"/>
                                </a>
                            </li>
                        <?php
                            endforeach;
                        ?>
                    <ul>
                </div>
                <div class="NextPage">
                    <a id="next" data-page="<?php echo $this->arrListItemsCount['next_page'];?>"
                       title="Next page" href="javascript:void(0);"></a>
                </div>
                <script type="text/javascript">
                    $(document).ready(function(){
                        $("#slideImage").slideImageEntry({
                            image: {width: 60, height: 60},
                            wrapper: {current: 0, total: 12, displayed: 6},
                            page: {
                                current: <?php echo $this->arrListItemsCount['current_page'];?>,
                                total: <?php echo $this->arrListItemsCount['total_pages'];?>
                            },
                            offset: {min: 0, max: 0, current: 0},
                            prev_page: "<?php echo $this->pageUrl(array_merge($this->extraValues, array('target' => 'detail', 'id_entry' => null, 'page' => $this->arrListItemsCount['prev_page']))); ?>",
                            next_page: "<?php echo $this->pageUrl(array_merge($this->extraValues, array('target' => 'detail', 'id_entry' => null, 'page' => $this->arrListItemsCount['next_page']))); ?>"
                        });
                    });
                </script>
            </div>
        </div>
        <div class="entry_info">
            <div class="social_actions">
                <!-- Share to another social networks -->
                 <?php
                    $url = $this->entry->getShareUrlSocialNetworks(array(), FALSE);
                    $url_facebook = $this->entry->getShareUrlSocialNetworks(array(), TRUE);
                    $furl = $this->social->getShareUrl('/contest/share/contest/id_page/'.$this->social->getIdPage().'/id_contest/'.$this->contest->id);
                    preg_match_all('/(http:.*?\.com\/.*?\/)/', $furl,$matches);
                    $durl = $matches[1][0].$this->pageUrl();
                ?>
                <?php if (!empty($this->contest->is_show_social_like_btns)):?>
                 <div class="like-another-social-networks">
                    <?php echo $this->partial('like-to-social-networks.phtml', array(
                        'url'			=> $url,
                        'url_facebook'	=> $url_facebook,
                        'id_object'		=> $this->entry->id,
                        'id_page'       => $this->id_page,
                        'id_user'		=> $this->id_user?$this->id_user:ID_USER_CHEAT_FOR_COUNT_SHARE,
                        'show_text'		=> true,
                        'message'		=> YouNet_Util::escapeForJs(sprintf($this->translate('REQUEST_MESSAGE'), $this->contest->title, $this->contest->getPageName($this->id_page))),
                        'send'			=> false,
                        'show_faces'	=> false,
                        'show_fb_like'	=> false,
                        'page_url'      => $_SERVER['HTTP_HOST'].$this->pageUrl(),
                        'img'           => STATIC_URL . '/media/image/' . $this->entry->image,
                        'description'   => nl2br($this->escape($this->entry->description)),
                        'title'         => $this->entry->title,
                        'contest_name' => $this->contest->title
                    ));?>
                </div>
                <?php endif;?>
                <div class="share-another-social-networks">
                    <?php echo $this->partial('share-to-social-networks.phtml', array(
                        'url'			=> $url,
                        'furl'          => $furl,
                        'url_facebook'	=> $url_facebook,
                        'durl'          => $durl,
                        'id_object'		=> $this->entry->id,
                        'id_page'       => $this->id_page,
                        'id_user'		=> $this->id_user?$this->id_user:ID_USER_CHEAT_FOR_COUNT_SHARE,
                        'show_text'		=> true,
                        'message'		=> YouNet_Util::escapeForJs(sprintf($this->translate('REQUEST_MESSAGE_ENTRY'), $this->contest->title, $this->contest->getPageName($this->id_page))),
                        'send'			=> false,
                        'show_faces'	=> false,
                        'show_fb_like'	=> false,
                        'page_url'      => $_SERVER['HTTP_HOST'].$this->pageUrl(),
                        'title'         => $this->entry->title,
                        'description'   => nl2br($this->escape($this->entry->description)),
                        'contest_name' => $this->contest->title,
                        'invite_url'    => $this->contest->getInviteUrlSocialNetworks(array()),
                        'is_contest'    =>  FALSE,
                    ));?>
                </div>
            </div>

            <div class="vote_panel">
                <?php if($this->entry->status== Core_Model_IEntry::STATUS_APPROVED):?>
                    <ul class="horizon">
                        <li>
                            <div style="display: none;" class="loading"></div>
                            <strong class="vote_number"><?php echo $this->number($this->entry->votes,'LABEL_NUM_VOTE'); ?></strong>
                            <input type='button'
                                   class='sm_button btn_vote <?php if(!$this->is_show_vote_button || $this->is_voted) echo "disabled";?>'
                                   value='<?php if($this->is_voted) echo "Voted"; else echo "Vote now";?>' />

                        </li>
                    </ul>
                    <?php if($this->is_show_vote_button && !$this->is_voted):?>
                        <script type="text/javascript">
                            $(document).ready(function(){
                                var str_per = '<?php echo $this->social->getOAuthScope() ?>';
                                <?php if ($this->contest->is_auto_post)  : ?>
                                    if (str_per== ""){
                                        str_per = 'publish_stream';
                                    }else{
                                        str_per = ',publish_stream';
                                    }
                                <?php endif ;?>
                                Social.bind('.btn_vote','click', function(e, response){
                                    var url     = "<?php echo $this->pageUrl(array_merge($this->extraValues, array('target' => 'vote', 'id_entry' => $this->entry->id))); ?>";
                                    var data    = {
                                        signed_request : response.authResponse.signedRequest
                                    };
                                    $(".vote_panel .loading").show();
                                    jQuery.post(url, data, function(result){
                                        $(".vote_panel .btn_vote").val("Voted");
                                        $(".vote_panel .btn_vote").addClass("disabled");
                                        $(".vote_panel .btn_vote").attr("disabled", "true");
                                        if(result.success == true){
                                            $(".vote_panel .vote_number").text(result.data);
                                            if(result.share == true){
                                                Social.share({
                                                    link    : "<?php echo $this->entry->getHrefWithIDUser($this->id_user) ?>"
                                                });
                                            }
                                        }
                                        $(".vote_panel .loading").hide();
                                    }, 'json' );
                                }, {
                                    scope   : str_per,
                                    title   : '<?php echo $this->translate('Confirm action') ?>',
                                    content : '<?php echo $this->translate('Please authorize before voting.') ?>'
                                });
                            });
                        </script>
                    <?php endif;?>
                <?php endif;?>
            </div>
        </div>
        <div class="permanent_link">
            <?php
                echo $this->partial('detail-permanent.phtml', array('url' => $this->entry->getHrefWithIDUser($this->id_user)));
            ?>
        </div>
    </div>
</div>
<div class="col_right">
    <div class="entry_info">
        <div class="photo_detail">
            <h3 class="title"><?php echo $this->escape($this->entry->title); ?></h3>
            <p>
                by
                <a target="_blank" href="<?php echo $this->entry->getLink();?>">
                    <?php echo $this->escape($this->entry->getCandidateName());?>
                </a>
                on
                <?php echo date($this->translate('DATE_FORMAT'), $this->entry->time_uploaded);?>
            </p>
            <div class="entry-description">
                <?php echo $this->shortDesc(nl2br($this->escape($this->entry->description)));?>
                <?php //echo nl2br($this->escape($this->entry->description)); ?>
            </div>
        </div>
    </div>
    <?php if ($this->contest->isAllowedComment()): ?>
        <?php echo $this->social->render('comment',
            array(
                'url'	=> $this->entry->getCommentUrl(),
                'width' => 320
            ))
        ?>
        <script type="text/javascript">
            $(document).ready(function(){
                var ajax_url = '<?php echo $this->baseUrl('/contest/index/notify')?>';
                var data = {
                    url:"<?php echo $this->social->getShareUrl('/contest/entry/view/from_page/'.$this->social->getIdPage().'/id_entry/'.$this->entry->id); ?>",
                    id_contest: "<?php echo $this->contest->id?>",
                    entry_name : "<?php echo $this->entry->title  ?>"
                };
                Social.handleCommentNotify(ajax_url, data);
            });
        </script>
    <?php endif; ?>
</div>
<div style="clear: both"></div>
<script type="text/javascript">
    $(document).ready(function(){
        var list_image = <?php echo json_encode($list_image);?>;
        $(list_image).preload();
    });
</script>
